package com.hu.zhcc.shiro.controller;

import com.github.pagehelper.PageInfo;
import com.hu.zhcc.shiro.entity.bo.Follow;
import com.hu.zhcc.shiro.entity.bo.HMemberofthefile;
import com.hu.zhcc.shiro.entity.vo.FollowVO;
import com.hu.zhcc.shiro.service.FollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * 体质评估
 */

@RestController
@CrossOrigin
@RequestMapping("/follow")
public class FollowController {
    @Autowired
    private FollowService followService;

    @GetMapping("")
    @ResponseBody
    public PageInfo<Follow> homeFollow(FollowVO followVO){
        PageInfo<Follow> followPageInfo = followService.pageQuery(followVO);
        return followPageInfo;
    }

    @PostMapping("")
    public ResponseEntity<?> saveCheckitem(@RequestBody Follow follow) {
        return followService.AddFollow(follow) ? ResponseEntity.noContent().build() :
                ResponseEntity.notFound().build();
    }
    @DeleteMapping("/{id}")
    public ResponseEntity<?> removeFollow(@PathVariable("id") Short id) {
        return followService.removeFollow(id) ? ResponseEntity.noContent().build() :
                ResponseEntity.notFound().build();
    }

    @PutMapping("/{id}")
    public ResponseEntity<Integer> updateRouter(@PathVariable("id") int id, @RequestBody Follow follow) {
        return followService.updateFollow(follow) ? ResponseEntity.noContent().build() :
                ResponseEntity.notFound().build();
    }

    @GetMapping("/{number}")
    public HMemberofthefile findBynumber(@PathVariable("number")String number) {
        return followService.findbynumber(number);
    }
}
